//
//  PersonalMainPageViewController.m
//  结伴
//
//  Created by 莫业金 on 16/8/25.
//  Copyright © 2016年 aleven. All rights reserved.
//

#import "PersonalMainPageViewController.h"
#import "PersonalMainPageTableViewCell.h"

@interface PersonalMainPageViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (weak, nonatomic) IBOutlet UITableView *tableView_main;

@property (nonatomic,strong)NSMutableArray *array_Description;

@end

@implementation PersonalMainPageViewController


- (NSMutableArray *)array_Description{
    if (!_array_Description) {
        _array_Description = [NSMutableArray array];
    }
    
    return _array_Description;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"个人资料卡";
    
    NSArray *array_One = [NSArray arrayWithObjects:@"昵称",@"性别",@"年龄",@"身份",@"地区",@"真实姓名",@"自我介绍",nil];
    NSArray *array_Two = [NSArray arrayWithObjects:@"个性签名",@"标签", nil];
    [self.array_Description addObject:array_One];
    [self.array_Description addObject:array_Two];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return self.array_Description.count + 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    if (section == 0) {
        return 1;
    }
    NSArray *array_main = self.array_Description[section - 1];
    
    return array_main.count;
    
}


-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    static NSString *ID_main = @"PersonalMainPageTableViewCell";
    PersonalMainPageTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID_main];
    if (!cell) {
        cell = [[[NSBundle mainBundle] loadNibNamed:ID_main owner:nil options:nil] lastObject];
    }
    
    if (indexPath.section == 0) {
        
        UIImageView *view = [[UIImageView alloc] initWithFrame:CGRectMake(15, 15, 70, 70)];
        view.image = [UIImage imageNamed:@"001"];
        [view.layer setMasksToBounds:YES];
        [view.layer setCornerRadius:35.0];
        
        cell.contentLabel.text = @"更换头像";
        cell.contentLabel.textColor = UnifiedColor;
        
        [cell addSubview:view];
        
    }else{
         NSArray *arr_main = self.array_Description[indexPath.section - 1];
        cell.DescriptionLabel.text = arr_main[indexPath.row];
    }
    
    if (indexPath.section == 1) {
        if (indexPath.row == 1 || indexPath.row == 5) {
            
             cell.contentLabel.textColor = UnifiedColor;
        }
    }
    
    
    return cell;
    
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.section == 0) {
        return 100.0;
    }
    
    return 50.0;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    
    if (section == 0) {
        return 10.0;
    }
    
    return 50.0;
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    
    return 0.1;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    
    if (section == 0) {
        return nil;
    }
    
    UIView *view_mian = [UIView new];
    view_mian.backgroundColor = f7fColor;
 
    CGFloat y = 10;
    NSString *iconName = @"jbzl";
    
    if (section == 2) {
        iconName = @"xqbq";
    }
    
    UIImageView *image = [[UIImageView alloc] initWithFrame:CGRectMake(15, y, 30, 30)];
    image.image = [UIImage imageNamed:iconName];
    
    UILabel *lable_main = [[UILabel alloc] initWithFrame:CGRectMake((CGRectGetMaxX(image.frame) + 10), y, 100, 35)];
    
    if (section == 1) {
        iconName = @"基本资料";
    }else{
        iconName = @"兴趣标签";
    }

    lable_main.text = iconName;
    lable_main.font = [UIFont systemFontOfSize:16.0];
    lable_main.textColor = ThreeColor;
    
    [view_mian addSubview:image];
    [view_mian addSubview:lable_main];
    
    
    return view_mian;
    
}



@end
